package com.davidk.survey.server.data;

import java.util.List;

import com.davidk.survey.server.model.QuestionItem;

public class QuestionItemDAO extends BaseDAO<QuestionItem> {
	public QuestionItemDAO() {
		super(QuestionItem.class.getName());
	}

	private static QuestionItemDAO singleton;

	public static QuestionItemDAO getInstance() {
		if (singleton == null)
			singleton = new QuestionItemDAO();
		return singleton;
	}

	public static QuestionItem getById(long id) {
		List<QuestionItem> ret = getInstance().getByKey(QuestionItem.class.getName(), "id", id);
		if (ret != null && ret.size() > 0) {
			return (QuestionItem) ret.get(0);
		}
		return null;
	}

	public static void saveQuestionnaire(QuestionItem ques) throws DataStoreException {
		getInstance().saveObj(ques);
	}
}
